namespace SanQiOther.Models
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class RewardDbContext : DbContext
    {
        public RewardDbContext()
            : base("name=RewardDbContext")
        {
        }

        public virtual DbSet<A_Attendance> A_Attendance { get; set; }
        public virtual DbSet<A_Attendance_Detail> A_Attendance_Detail { get; set; }
        public virtual DbSet<A_Attendance_Log> A_Attendance_Log { get; set; }
        public virtual DbSet<A_Attendance_Sys> A_Attendance_Sys { get; set; }
        public virtual DbSet<A_Business> A_Business { get; set; }
        public virtual DbSet<A_Delay> A_Delay { get; set; }
        public virtual DbSet<A_Delay_Detail> A_Delay_Detail { get; set; }
        public virtual DbSet<A_Leave> A_Leave { get; set; }
        public virtual DbSet<A_Main> A_Main { get; set; }
        public virtual DbSet<A_SignIn> A_SignIn { get; set; }
        public virtual DbSet<A_Terminate> A_Terminate { get; set; }
        public virtual DbSet<dict_car> dict_car { get; set; }
        public virtual DbSet<dict_dept> dict_dept { get; set; }
        public virtual DbSet<dict_team> dict_team { get; set; }
        public virtual DbSet<dict_team_day> dict_team_day { get; set; }
        public virtual DbSet<dict_team_detail> dict_team_detail { get; set; }
        public virtual DbSet<dict_team_type> dict_team_type { get; set; }
        public virtual DbSet<dict_vacation> dict_vacation { get; set; }
        public virtual DbSet<dict_Vacation_detail> dict_Vacation_detail { get; set; }
        public virtual DbSet<member> member { get; set; }
        public virtual DbSet<Module> Module { get; set; }
        public virtual DbSet<dict_Dormitory> dict_Dormitory { get; set; }
        public virtual DbSet<Role> Role { get; set; }
        public virtual DbSet<RolePermissions> RolePermissions { get; set; }
        public virtual DbSet<user> user { get; set; }
        public virtual DbSet<v_A_Attendance> v_A_Attendance { get; set; }
        public virtual DbSet<v_A_Business> v_A_Business { get; set; }
        public virtual DbSet<v_A_Delay> v_A_Delay { get; set; }
        public virtual DbSet<v_A_Leave> v_A_Leave { get; set; }
        public virtual DbSet<v_A_Main> v_A_Main { get; set; }
        public virtual DbSet<v_A_SignIn> v_A_SignIn { get; set; }
        public virtual DbSet<v_A_Terminate> v_A_Terminate { get; set; }
        public virtual DbSet<v_dict_team> v_dict_team { get; set; }
        public virtual DbSet<v_member> v_member { get; set; }
        public virtual DbSet<v_Module> v_Module { get; set; }
        public virtual DbSet<v_user> v_user { get; set; }
        public virtual DbSet<v_vacation> v_vacation { get; set; }

        public virtual DbSet<v_dict_Dormitory_Detail> v_dict_Dormitory_Detail { get; set; }

        public virtual DbSet<car_main> car_main { get; set; }

        public virtual DbSet<v_car_detail> v_car_detail { get; set; }

        public virtual DbSet<bgs_car_main> bgs_car_main { get; set; }

        public virtual DbSet<v_bgs_car_main> v_bgs_car_main { get; set; }

        public virtual DbSet<bgs_car_dept_main> bgs_car_dept_main { get; set; }

        public virtual DbSet<v_bgs_car_dept_main> v_bgs_car_dept_main { get; set; }
        

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Module>()
                .Property(e => e.url)
                .IsUnicode(false);

            modelBuilder.Entity<Module>()
                .Property(e => e.icon)
                .IsUnicode(false);

            modelBuilder.Entity<user>()
                .Property(e => e.userpwd)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<v_Module>()
                .Property(e => e.url)
                .IsUnicode(false);

            modelBuilder.Entity<v_Module>()
                .Property(e => e.icon)
                .IsUnicode(false);

            modelBuilder.Entity<v_user>()
                .Property(e => e.userpwd)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<dict_car>()
                 .HasMany(e => e.car_main)
                 .WithRequired(e => e.dict_car)
                 .HasForeignKey(e => e.car)
                 .WillCascadeOnDelete(false);

        }
    }
}
